package chaoyue.study.jdbc.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.ResourceBundle;

public class DbUtils {
    /**
     * 连接获取工具类
     */
    public static Connection getConnection() throws Exception {
        // 读取配置文件
        ResourceBundle resource = ResourceBundle.getBundle("jdbc");
        // 加载驱动
        Class.forName(resource.getString("driver"));
        // 获取链接
        return DriverManager.getConnection(resource.getString("url"),
                resource.getString("username"),
                resource.getString("password"));
    }
}
